package org.ticketing.controller;

import javax.persistence.*;

import org.ticketing.model.*;

public class PrivateAreaManager {
	
	public void cancelReservation(int reservationId) {
		EntityManagerFactory factory = Persistence.createEntityManagerFactory("DB");
		EntityManager manager = factory.createEntityManager();
		
		// Reservation reservation = manager.find(Reservation.class, reservationId);
		// manager.detach(reservation);
	}
	
	public void modifyReservation(int reservationId) {
		EntityManagerFactory factory = Persistence.createEntityManagerFactory("DB");
		EntityManager manager = factory.createEntityManager();
		
		// Reservation reservation = manager.find(Reservation.class, reservationId);
		
		// Redirect to reservation page
		// Populate reservation page with reservation's data
		// Highlight already-selected seats
	}
	
	public void resetData() {
		// Reset data in form
	}

	public void saveData(String username, String pwd) {
		EntityManagerFactory factory = Persistence.createEntityManagerFactory("DB");
		EntityManager manager = factory.createEntityManager();
		
		// Add control about in-use usernames
		
		User user = manager.find(User.class, username);
		
		manager.detach(user);
		
		manager.persist(new User(username, pwd));
	}
	
	public void switchPage(int pageNumber) {
		switch(pageNumber) {
			// Redirect to page identified by pageNumber
			// Populate page with proper data
		}
	}
	
}
